package tools;

import java.io.Serializable;
import java.util.AbstractMap;
import java.util.AbstractSet;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;

public class ArrayMap<K, V> extends AbstractMap<K, V>
        implements Serializable {

    public static final long serialVersionUID = 9179541993413738569L;
    private transient Set<? extends Map.Entry<K, V>> entries = null;
    private ArrayList<Entry<K, V>> list;
    private int i;

    public ArrayMap() {
        this.list = new ArrayList();
    }

    public ArrayMap(Map<K, V> map) {
        this.list = new ArrayList();
        putAll(map);
    }

    public ArrayMap(int initialCapacity) {
        this.list = new ArrayList(initialCapacity);
    }

    public Set<Map.Entry<K, V>> entrySet() {
        if (this.entries == null) {
            this.entries = new AbstractSet() {
                public void clear() {
                    throw new UnsupportedOperationException();
                }

                public Iterator<ArrayMap.Entry<K, V>> iterator() {
                    return ArrayMap.this.list.iterator();
                }

                public int size() {
                    return ArrayMap.this.list.size();
                }
            };
        }
        return (Set<java.util.Map.Entry<K, V>>) entries;
    }

    public V put(K key, V value) {
        int size = this.list.size();
        Entry entry = null;

        if (key == null) {
            for (int i = 0; i < size; i++) {
                entry = (Entry) this.list.get(i);
                if (entry.getKey() == null) {
                    break;
                }
            }
        }
        for (int i = 0; i < size; i++) {
            entry = (Entry) this.list.get(i);
            if (key.equals(entry.getKey())) {
                break;
            }
        }
        Object oldValue = null;
        if (i < size) {
            oldValue = entry.getValue();
            entry.setValue(value);
        } else {
            this.list.add(new Entry(key, value));
        }
        return (V) oldValue;
    }

    public static class Entry<K, V>
            implements Map.Entry<K, V>, Serializable {

        public static final long serialVersionUID = 9179541993413738569L;
        protected K key;
        protected V value;

        public Entry(K key, V value) {
            this.key = key;
            this.value = value;
        }

        public K getKey() {
            return this.key;
        }

        public V getValue() {
            return this.value;
        }

        public V setValue(V newValue) {
            Object oldValue = this.value;
            this.value = newValue;
            return (V) oldValue;
        }

        public boolean equals(Object o) {
            if (!(o instanceof Map.Entry)) {
                return false;
            }
            Map.Entry e = (Map.Entry) o;
            return (this.key == null ? e.getKey() == null : this.key.equals(e.getKey())) && (this.value == null ? e.getValue() == null : this.value.equals(e.getValue()));
        }

        public int hashCode() {
            int keyHash = this.key == null ? 0 : this.key.hashCode();
            int valueHash = this.value == null ? 0 : this.value.hashCode();
            return keyHash ^ valueHash;
        }

        public String toString() {
            return this.key + "=" + this.value;
        }
    }
}

/* Location:           C:\Users\文炳\Desktop\ApkIDE3.1\114MS.jar
 * Qualified Name:     tools.ArrayMap
 * JD-Core Version:    0.6.2
 */